//
//  NSMutableData+TYSafe.h
//  TYFoundation
//
//  Created by 郭艺伟 on 2019/2/28.
//

#import <Foundation/Foundation.h>

#ifndef TYDataSubDataWithRange
#define TYDataSubDataWithRange(data,range,subData)                         \
if (((range).location) >= 0 && (range).length > 0 && (range).location <= [(data) length] && NSMaxRange(range)<=[(data) length]) {                  \
(subData) = [(data) subdataWithRange:(range)];                          \
} else { \
(subData) = nil;\
}
#endif

#ifndef TYDataSetData
#define TYDataSetData(data,aData)                         \
if ((aData)) {                  \
[(data) setData:(aData)];                          \
}
#endif


@interface NSMutableData (TYSafe)

@end
